#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <kvs.h>

#include "defines.h"

int size_in_G;
char disk_pathname[PATHNAME_LEN];

int main(int argc, char** argv)
{
	KVS_SET kvs;
	FILE* fp;
	
/* parse command line. */
	if (argc!=3)
	{
		printf ("usage: size_in_G, disk_pathname.\n");
		return 1;
	}

	size_in_G=0;
	memset(disk_pathname, 0, sizeof(disk_pathname));

	sscanf(argv[1], "%d", &size_in_G);
	if (strlen(argv[2])>=PATHNAME_LEN)
	{
		printf ("too long:%s\n", argv[2]);
		return 1;
	}
	sscanf(argv[2], "%s", disk_pathname);

/* init KVS_SET */
	kvs.init_type=KVS_CREATE;
	kvs.size_in_g=size_in_G;
	strcpy(kvs.disk_file, disk_pathname);
	strcpy(kvs.log, "/tmp/kvs.log");
	strcpy(kvs.disk_log, "/tmp/kvs_disk.log");
	strcpy(kvs.sync_log, "/tmp/kvs_sync.log");
	strcpy(kvs.index_log, "/tmp/kvs_index.log");

	kv_init_2(&kvs);

	kv_exit();

/* write to backup.conf */
	fp=fopen("backup.conf","w");	
	fprintf (fp, "%d\n", size_in_G);
	fprintf (fp, "%s\n", disk_pathname);
	fclose(fp);
			
	return 0;
}

